#include "bossPuppetController.h"

#include <cstdlib>

void BossPuppetController::manipulate()
{
	Sprite *p_sprite = puppet1->getSprite();
	Sprite *b_sprite = puppet2->getSprite();

	Vector2f p_c = p_sprite->getCenter();
	Vector2f b_c = b_sprite->getCenter();

	Vector2f b2p = p_c - b_c;

	// Follow the player
	if(b2p.magnitude() > 500) {
		if(p_c[0] < b_c[0]) {
			puppet2->left();
		} else {
			puppet2->right();
		}
	}

	// Ranomly jump
	int jump = rand() % 1000;
	if(jump < 10) {
		puppet2->jump();
	}

/*
	// Ranomly move
	int move = rand() % 1000;
	if(move < 10) {
		puppet2->left();
	} else if(move > 900) {
		puppet2->right();
	}
*/

	// Shoot like crazy!!!
	Vector2f dir = b2p.normalize();
	int shoot = rand() % 500;
	if(shoot < 10) {
		puppet2->shoot(dir);
	}
}
